
enum KAIGUAN {
    //% block="开"
    HIGH,
    //% block="关"
    LOW
}

//% color="#AA278D" iconWidth=50 iconHeight=40
namespace led {
    //% block="控制[YINJIAO]引脚的LED灯[KAIGUAN]" blockType="command"
    //% YINJIAO.shadow="dropdown" YINJIAO.options="PIN_DigitalWrite" 
    //% KAIGUAN.shadow="dropdown" KAIGUAN.options="KAIGUAN" KAIGUAN.defl="HIGH"
    export function kaiguan(parameter: any, block: any) {
        let YINJIAO = parameter.YINJIAO.code;
        let KAIGUAN = parameter.KAIGUAN.code;
        Generator.addCode(`digitalWrite(${YINJIAO},${KAIGUAN});`);
    }
    
    //% block="控制[YINJIAO]引脚的LED灯亮度为[LIANGDU]" blockType="command"
    //% YINJIAO.shadow="dropdown" YINJIAO.options="PIN_AnalogWrite" 
    //% LIANGDU.shadow="range"   LIANGDU.params.min=0    LIANGDU.params.max=255    LIANGDU.defl=255
    export function liangdu(parameter: any, block: any) {
        let YINJIAO = parameter.YINJIAO.code;
        let LIANGDU = parameter.LIANGDU.code;
        
        Generator.addCode(`analogWrite(${YINJIAO},${LIANGDU});`);
    }

}
